<template>
  <div class="app-container">
    <el-form :model="form" :rules="passRule" ref="passwordForm" style="width: 400px;" label-width="80px">
      <el-form-item prop="setPwdNow">
        <div>
          <el-radio v-model="form.setPwdNow" label="1" >通过手机号重置密码</el-radio>
        </div>
        <el-radio v-model="form.setPwdNow" label="2" >通过邮箱重置密码</el-radio>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="doSave({action: 'saveForm', form: 'passwordForm'})" v-loading="loading">申请重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import {updateMemberPass} from '@/services/api/member'
  import { form} from '@/build'
  export default {
    name: "edit-member-pass",
    mixins:[form],
    data(){
      return {
        form: {
          setPwdNow: undefined
        },
        passRule: {
          setPwdNow: [
            {required: true, message:'重置条件为必选项', trigger: 'blur' }
          ]
        },
      }
    },
    mounted(){
      const {member_id} = this.$store.state.member
      this.form.member_id = member_id
      this.bindSave(updateMemberPass, 'saveForm', 'form', {
        afterSuccess: () => {
          this.$notify({
            type: 'success',
            message:'重置成功'
          })
        }
      });
    },
    methods:{
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            // this.$store.commit('SHOW_APPLY_MODAL',{data:this.form,from:'memberPassword'})
            // updateMemberPass(this.passwordForm).then(([result, data]) => {
            //   if (result) {
            //     this.$message({
            //       type:'success',
            //       message: data.msg
            //     })
            //   }
            // });
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
    }

  }
</script>

<style scoped>
</style>
